var WaterMarker = {};
WaterMarker.map = new Array();

WaterMarker.AddWaterMark = function(input_control, text, color)
{
	function clearMessage(event){
		var input = event.currentTarget;
		var id = dojo.attr(input,"id");
		var props = WaterMarker.map[id];
		if(input.value == props.text)
			input.value = "";
		dojo.style(input, "color", props.DefaultColor);
		dojo.style(input,"fontStyle","normal");	
	}

	function insertMessage(event){
		var input = event.currentTarget;
		var id = dojo.attr(input,"id");
		var props = WaterMarker.map[id];
		if(input.value.length == 0){
			dojo.style(input,"color",props.WatermarkColor);	
			dojo.style(input,"fontStyle","italic");	
			input.value = text;
			
		}
		else{
			dojo.style(input,"color",props.DefaultColor);
			dojo.style(input,"fontStyle","normal");	
		}
	}

	if(!color)
		color = "#aaa";
	var defcolor = dojo.style(input_control,"color");
	var id = dojo.attr(input_control,"id");
	WaterMarker.map[id] = {text:text,obj:input_control,DefaultColor:defcolor,WatermarkColor:color};
	
	dojo.connect(input_control,"onfocus",clearMessage);
	dojo.connect(input_control,"onblur", insertMessage);								
	
	insertMessage({currentTarget:input_control});
}